<script type="text/javascript">
//<![CDATA[
var dailydealTimeCounters = new Array();
var i = 0;
//]]>
</script>
<div class="block block-subscribe block-dailydeal-new">
    <div class="block-title"><strong><span><?php echo $this->getTitle() ? $this->getTitle() : $this->__('Daily Deal'); ?></strong></span></div>
        <div class="block-content">
            <?php
			$deals       = $this->getSidebarDeals();
			$_coreHelper = $this->helper('core');
			$_helper     = $this->helper('catalog/output');
			?>
			<?php if (!$deals->count()): ?>
				<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
			<?php else: ?>
				<div class="category-products">
				<?php $_iterator = 0; ?>
					<?php $count = 0;
					foreach ($deals as $_product): ?>
						<?php $deal = $this->getDealByProduct($_product->getEntityId()); ?>
						<?php if (!$deal->getId()) continue; ?>
						<div class="sidebardailydeal">
                    <div class="item<?php if (++$_iterator == sizeof($deals)) echo 'last' ?>">
						<div class="item-daily-top">
                        <?php // Product Image
						if ($deal->getThumbnailImage()) {
							$image = Mage::getBaseUrl('media') . $deal->getThumbnailImage();
						} else {
							$image = $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(180, 180);
						}
						?>
							<a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->getImageLabel($_product, 'small_image') ?>" class="sidebar-product-image">
                            <img src="<?php echo $image; ?>" width="180" height="180" alt="<?php echo $this->getImageLabel($_product, 'small_image') ?>"/>
                        </a>

						<ul class="dailydeal-price">
							<li class="special-price">
								<?php
								echo $_coreHelper->currency($deal->getDealPrice());
								?>
							</li>
							<li class="old-price"><?php echo $_coreHelper->currency($_product->getPrice()) ?></li>
						</ul>
					</div>

						<?php // Product description ?>

						<div class="bottom-home-dailydeal">
							<ul class="time-left">
                                <?php $now_time = Mage::getModel('core/date')->timestamp(time()) ?>
								<?php
								$end_time = Mage::getModel('core/date')->timestamp(strtotime($deal->getCloseTime()));
								?>
								<div class="timeleft timeleft_<?php echo $this->getType() . $_product->getId() ?>"> </div>

							</ul>
						</div>

						<h2 class="dailydeal-sidebar-product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $_product->getName() ?>"><?php echo $deal->getTitle() ?></a>
                	</h2>

                    </div>
                </div>
						<script type="text/javascript">
		//<![CDATA[
		dailydealTimeCounters[i] = new DailydealTimeCounter('<?php echo $now_time ?>', '<?php echo $end_time ?>', '<?php echo $deal->getId() ?>');
		dailydealTimeCounters[i].setTimeleft('timeleft_<?php echo $this->getType() . $_product->getId() ?>');
		//]]>
		</script>
					<?php endforeach; ?>
                </div>
			<?php endif; ?>
        </div>
		<script type="text/javascript">decorateGeneric($$('.block-dailydeal .sidebardailydeal'), ['odd', 'even', 'first', 'last'])</script>
</div>